// pages/component/login_dialog/login_dialog.js
const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'


Component({
  /**
   * 组件的属性列表
   */
  properties: {
    showInput: Boolean,
  },

  /**
   * 组件的初始数据
   */
  data: {
  
    avatar: defaultAvatarUrl,
    nickname: '',
  },

  /**
   * 组件的方法列表
   */
  methods: {
    login(){
      this.setData({
        showInput:true,
      })
    },
    onClose(){
      this.setData({
        showInput:false
      })
    },
    onInput(e) {
      this.setData({
        nickname: e.detail.value
      })
    },
    onChooseAvatar(e) {
      const { avatarUrl } = e.detail
      this.setData({
        avatar: avatarUrl
      })
    },
    sureLogin(){
      if (this.data.nickname == '') {
        wx.showToast({
          title: '请输入昵称',
          icon: 'none',
        });
      }else{
          this.triggerEvent('headinfo', {
            headurl: this.data.avatar,
            headname: this.data.nickname,
            showInput:false
          })
      }
    }
  }
})
